<template>
  <div id="app">
    <el-container>
      <el-header>
        <el-row>
          <el-col :span="3">&nbsp;</el-col>
          <el-col :span="21">
            <el-button
              icon="el-icon-message"
              type="primary"
              @click="isCollapse = !isCollapse"></el-button>
          </el-col>
        </el-row>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            router="true"
            :collapse="isCollapse">
            <component
              v-for="item in arr"
              :key="item.index"
              :index="item.index"
              v-bind:is="item.children ? 'el-submenu' : 'el-menu-item'">
              <template v-if="item.children" slot="title">
                <i class="el-icon-location"></i>
                <span slot="title">{{ item.title }}</span>
              </template>
              <div v-else>
                <i class="el-icon-setting"></i>
                <span slot="title">{{ item.title }}</span>
              </div>
              <component
                v-for="item1 in item.children"
                :key="item1.index"
                :index="item1.index"
                v-bind:is="item1.children ? 'el-submenu' : 'el-menu-item'">
                <template v-if="item1.children" slot="title">
                  <i class="el-icon-location"></i>
                  <span slot="title">{{ item1.title }}</span>
                </template>
                <div v-else>
                  <i class="el-icon-setting"></i>
                  <span slot="title">{{ item1.title }}</span>
                </div>
                <component
                  v-for="item2 in item1.children"
                  :key="item2.index"
                  :index="item2.index"
                  v-bind:is="item2.children ? 'el-submenu' : 'el-menu-item'">
                  <template v-if="item2.children" slot="title">
                    <i class="el-icon-location"></i>
                    <span slot="title">{{ item2.title }}</span>
                  </template>
                  <div v-else>
                    <i class="el-icon-setting"></i>
                    <span slot="title">{{ item2.title }}</span>
                  </div>
                </component>
              </component>
            </component>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { menulist } from "@/model/menulist";
export default {
  name: "home-view",
  data() {
    return {
      currentTabComponent: "",
      btnTitle: "打开",
      txt: "",
      isCollapse: false,
      arr: menulist,
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
};
</script>

<style scoped>
.el-row {
  height: 100%;
  margin: 0;
  .el-col {
    height: 100%;
    display: flex;
    align-items: center;
  }
}
.el-container {
  margin: 0;
  padding: 0;
}
.el-header {
  height: 20%;
  padding: 0 !important;
}
.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  height: 100%;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}

.el-main {
  background-color: #ffffff;
  color: #333;
  text-align: center;
  height: 100%;
  padding: 5px;
}
#app {
  background: #f1ce99;
  height: 100vh;
  > .el-container {
    height: 100%;
    > .el-container {
      background: #6aacef;
      height: 80%;
    }
  }
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>
